﻿using System;

namespace Practice06
{
    class Program
    {
        /// <summary>
        /// 编一个程序，输入二个正整数，求出它们的最大公约数。
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Console.WriteLine("请输入第一个正整数：");
            int num1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("请输入第二个正整数：");
            int num2 = Convert.ToInt32(Console.ReadLine());
            int gcd = 0;
            if (num1 % num2 == 0) 
            {
                Console.WriteLine($"最大公因子(greatest common divisor)是：{num2}");
            }
            else
            {
                do
                {
                    gcd = num1 % num2;
                    num1 = num2;
                    num2 = gcd;
                } while (gcd>0);
            }
            if (num2 ==0)
            {
                Console.WriteLine($"最大公因子(greatest common divisor)是：{num1}");
            }
        }
    }
}
